from setuptools import setup, find_packages
import os

# 获取所有redfire_framework的子包
def get_redfire_packages():
    packages = []
    framework_path = "backend/redfire_framework"
    
    # 添加主包
    packages.append("redfire_framework")
    
    # 遍历所有子目录
    for root, dirs, files in os.walk(framework_path):
        # 跳过__pycache__目录
        dirs[:] = [d for d in dirs if d != "__pycache__"]
        
        # 如果目录包含__init__.py，则是一个包
        if "__init__.py" in files:
            # 计算相对于backend的包路径
            rel_path = os.path.relpath(root, "backend")
            package_name = rel_path.replace(os.sep, ".")
            if package_name != "redfire_framework":  # 主包已经添加
                packages.append(package_name)
    
    return packages

setup(
    name="redfire",
    version="0.1.0",
    packages=get_redfire_packages(),
    package_dir={"": "backend"},
    include_package_data=True,
    install_requires=[
        "fastapi>=0.104.0",
        "uvicorn[standard]>=0.24.0",
        "pydantic>=2.4.0",
        "sqlalchemy>=2.0.0",
        "dependency-injector>=4.41.0",
        "python-jose[cryptography]>=3.3.0",
        "passlib[bcrypt]>=1.7.4",
        "python-multipart>=0.0.6",
        "aiofiles>=23.2.1",
    ],
)
